package com.zd.kids.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.IntentUtils;
import com.blankj.utilcode.util.SpanUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.hyy.libray.presenter.IBasePresenter;
import com.hyy.libray.ui.activity.BaseActivity;
import com.zd.kids.R;
import com.zd.kids.common.UserInfoConfig;

import butterknife.OnClick;

public class HelpActivity extends BaseActivity {

    /**
     * 获取布局文件地址
     */
    @Override
    public int getLayoutResId() {
        return R.layout.activity_help;
    }

    /**
     * 初始化布局
     */
    @Override
    public void initView() {
        initTitle(getString(R.string.need_help));

        TextView textView = findViewById(R.id.tv_account);

        textView.setText(getString(R.string.your_account) + UserInfoConfig.getInstance().getAccount());

        SpanUtils.with(textView)
                .append("您的帳戶：")
                .setForegroundColor(0xFF000000)
                .append(UserInfoConfig.getInstance().getAccount())
                .setForegroundColor(0xFF58C7B7)
                .create();
    }

    /**
     * 获取Presenter，不用MVP，可以为空
     *
     * @return
     */
    @Override
    protected IBasePresenter onBasePresenter() {
        return null;
    }

    @OnClick({R.id.rl_whatapp, R.id.rl_phone, R.id.rl_email})
    public void onViewClicked(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.rl_whatapp:
                if (AppUtils.isAppInstalled("com.whatsapp")) { //判断是否装了whatsAPP
                    Uri uri = Uri.parse("smsto:" + getString(R.string.gapsk_ai_qm_whats_app).replace(" ", ""));
                    Intent i = new Intent(Intent.ACTION_SENDTO, uri);
                    i.setPackage("com.whatsapp");
                    startActivity(Intent.createChooser(i, ""));
                } else {
                    ToastUtils.showShort(getString(R.string.whatsapp));
                }
                break;
            case R.id.rl_phone:
                intent = IntentUtils.getDialIntent(getString(R.string.gapsk_ai_qm_phone).replace(" ", ""));
                startActivity(intent);
                break;
            case R.id.rl_email:

                intent = new Intent(android.content.Intent.ACTION_SEND);
                intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"info@gapsktraining.org"});
                intent.setType("message/rfc822");
                intent.setClassName("com.android.email", "com.android.email.activity.MessageCompose");
                startActivity(Intent.createChooser(intent, "请选择邮件发送软件"));
                break;
        }
    }
}
